<?php

namespace App\Http\Controllers\Api;

use App\Http\Resources\UserResource;
use App\User;

class UserController extends ApiController
{

    public function index()
    {

//        $user = User::query()->find(1);
//        // 响应一个元素
//        return $this->item($user, UserResource::class);

        // $users = User::all();
        // // 响应一个元素集合
        // return $this->collection($users,UserResource::class);

         $users = User::query()->paginate();
         // 分页响应
         return $this->paginator($users, UserResource::class);

        // // 无内容响应
        // $this->noContent();
        // // 一个 bad request 错误
        // $this->errorBadRequest();
    }
}
